<template>
    <div class="app-container">
        <el-table :data="tableData" v-loading="loading" border>
            <el-table-column prop="planname" label="预案名称" width="180" />
            <el-table-column prop="unitname" label="单位名称" width="180" />
            <el-table-column prop="depId" label="部门名称" width="180" />
            <el-table-column prop="plantype" label="预案类型" width="180" />
            <el-table-column prop="depleaderId" label="部门审核领导" width="180" />
            <el-table-column prop="unitleaderId" label="分管审核领导" width="180" />
            <el-table-column prop="adddate" label="修订日期" width="180" />
            <el-table-column prop="stateText" label="状态" width="180" />
            <el-table-column fixed="right" label="操作" align="center" width="100">
                <template #default="scope">
                    <el-button type="primary" size="small" link
                        @click="planBuildRef.showUnitLeaderPlanAudit(scope.row)">
                        <el-icon class="me-1">
                            <CircleCheck />
                        </el-icon>
                        审核
                    </el-button>
                </template>
            </el-table-column>
        </el-table>

        <pagination v-show="total > 0" v-model:page="paging.pageNum" v-model:limit="paging.pageSize" :total="total"
            @pagination="getList" />

        <AddEditPlanBuild ref="planBuildRef" @refresh-list="getList" />

    </div>
</template>

<script setup>
import PageHeader from "@/components/PageHeader/index.vue";
import { CircleCheck } from "@element-plus/icons-vue";
import { useTemplateRef } from "vue";
import { getFgLeaderPlanList } from "@/api/PlanManage/Plan.js";
import AddEditPlanBuild from "@/views/PlanManage/PlanBuild/components/AddEditPlanBuild.vue";
import PageEnum from "@/enum/PageEnum.js";

const loading = ref(false)
const total = ref(0)
const paging = ref({
    // 页码
    pageNum: 1,
    // 分页数量
    pageSize: PageEnum.SIZE
})
const queryParams = ref({
    name: '',
    status: '1'
})

const tableData = ref([])

const planBuildRef = useTemplateRef('planBuildRef')

onMounted(() => getList())

// 获取列表
const getList = async () => {
    loading.value = true;
    const res = await getFgLeaderPlanList({}, paging.value)
    total.value = res.total
    tableData.value = res.rows
    loading.value = false
}
</script>

<style scoped lang="scss"></style>